package com.funny.stock.base.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonUtil {
    private static ObjectMapper objectMapper = new ObjectMapper();

    public static String toJson(Object object) {
        try {
            return objectMapper.writeValueAsString(object);
        } catch (JsonProcessingException e) {
//            e.printStackTrace();
        }
        return "";
    }

    public static <T> T parseJson(String json,Class<T> object)  {
        try {
            return objectMapper.readValue(json,object);
        } catch (JsonProcessingException e) {
//            e.printStackTrace();
        }
        return null;
    }
}